<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<link rel="stylesheet" href="/static/css/stylemain.css">
<link rel="stylesheet" href="/static/layui/css/layui.css">
<script src="/static/layui/layui.all.js"></script>
<script type="text/javascript" src="/static/js/jquery.js"></script>
</head>
<body>
<div class="demo-tree" id="orgtree"></div>

<script type="text/javascript">
var tree = layui.tree;

layui.use([], function(){
		 
});

function child(flag,morg){
	getOrgList(flag,morg);
}

function getOrgList(flag,morg){
	$.ajax({
		contentType: "application/json;charset=UTF-8",
		url : "orgtree",
		type : "post",
		dataType : "json",
		success : function(msg) {
			debugger;
			tree.render({
				  elem: '#orgtree'				  
				  ,data:msg
				  ,onlyIconControl: true  //是否仅允许节点左侧图标控制展开收缩
				  ,click: function(obj){
				      debugger;
				      var index = parent.layer.getFrameIndex(window.name);
				      
				      if(flag == "lockmanage_org"){
				    	  if(obj.data.id != parent.$('#org_id').val()){
				    		  parent._susers = null;
					    	  parent.$('#operators')[0].innerHTML = "";
				    	  }
				    	  
				      }else if(flag == "lockmission_org" || flag == "multilockmanage_org"){
				    	  if(obj.data.id != parent.$('#org_id').val()){
				    		  parent._slocks = [];
				    		  parent._sauthusers = [];
					    	  parent.$('#slocks')[0].innerHTML = "";
					    	  parent.$('#lockauthuser')[0].innerHTML = "";
					    	  parent.$('#operators')[0].innerHTML = "";					    	  
				    	  }
				      }else if(flag == "keymanage_org"){
				    	  if(obj.data.id != parent.$('#org_id').val()){
				    		  parent._owner = [];
					    	  parent.$('#owner')[0].innerHTML = "";
				    	  }
				      }
				      
				      if(morg == 'morg'){
				    	  parent.$('#f_managerorg').val(obj.data.title);
					      parent.$('#morg_id').val(obj.data.id);
				      }else{				    	  
					      parent.$('#f_orgname').val(obj.data.title);
					      parent.$('#org_id').val(obj.data.id);
					      parent.$("#org_id").trigger("input");
				      }
				      parent.layer.close(index);
				    } 
				});		
			
		},
        error : function(e){
        	//dispalyEasyUILoad();
            alert(e.status);
            alert(e.responseText);
        }
	});
}

</script>

</body>
</html>
